package com.honvay.cola.cloud.construction.controller;


import com.honvay.cola.cloud.construction.entity.WorkType;
import com.honvay.cola.cloud.construction.service.WorkTypeService;
import com.honvay.cola.cloud.framework.base.controller.BaseController;
import com.honvay.cola.cloud.framework.core.protocol.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 工种 控制器
 * </p>
 *
 * @author stonihiy
 * @since 2018-10-11
 */
@RestController
@RequestMapping("/construction/workType")
@Api(tags = "工种 接口")
public class WorkTypeController extends BaseController {

        @Autowired
        private WorkTypeService workTypeService;

        /**
         * 获取工种列表
         */
        @GetMapping(value = "/list")
        @ApiOperation("获取工种列表")
        public Result<List<WorkType>> list() {
            return this.success(workTypeService.selectList());
        }

        /**
         * 新增工种
         */
        @PostMapping(value = "/add")
        @ApiOperation("新增工种")
        public Result<String> add(WorkType workType) {
            workTypeService.insert(workType);
            return this.success();
        }

        /**
         * 删除工种
         */
        @PostMapping(value = "/delete/{id}")
        @ApiOperation("删除工种")
        public Result<String> delete(@PathVariable("id") Long id) {
            workTypeService.deleteById(id);
            return this.success();
        }

        /**
         * 修改工种
         */
        @PostMapping(value = "/update")
        @ApiOperation("修改工种")
        public Result<String> update(WorkType workType) {
            workTypeService.updateById(workType);
            return this.success();
        }

        /**
         * 获取工种
         */
        @GetMapping(value = "/get/{id}")
        @ApiOperation("获取工种")
        public Result<WorkType> get(@PathVariable("id") Long id) {
            return this.success(workTypeService.selectById(id));
        }
}

